package com.xuan.bkm.service.user.admin.controller;

import com.xuan.bkm.constants.RespCode;
import com.xuan.bkm.constants.RespConstants;
import com.xuan.bkm.dto.HttpResp;
import com.xuan.bkm.entity.Admin;
import com.xuan.bkm.service.user.admin.service.IAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;


@RestController
@RequestMapping("/api/admin")
@Api("管理员模块")
public class AdminController {

    @Autowired
    private IAdminService ias;

    @GetMapping("/login")
    @ApiOperation("登录模块")
    public HttpResp login(String username,String password){
        Admin admin=ias.login(username, password);
        //登录成功
        return new HttpResp
                .Builder()
                .code(RespCode.LOGIN_SUCCEED.getCode())
                .msg(RespCode.LOGIN_SUCCEED.getName())
                .time(LocalDateTime.now())
                .results(RespConstants.LOGIN_SUCCEED)
                .builder();
    }

}
